[PATCH] fix: generated udev rules does not work due to incorrectline format
Problem consists of missing =sign in comparison with SUBSYSTEM and
missing new line character at the end of line. As a result incremental
for hot-plugs of bare disks does not work.
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski [at] intel.com>
---
policy.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/policy.c b/policy.c
index afb640f..2a9fe5c 100644
--- a/policy.c
+++ b/policy.c
[at] [at] -786,14 +786,14 [at] [at] char *find_rule(struct rule *rule, char *rule_type)
}
#define UDEV_RULE_FORMAT \
-"ACTION==\"add\", SUBSYSTEM=\"block\", " \
+"ACTION==\"add\", SUBSYSTEM==\"block\", " \
"ENV{DEVTYPE}==\"%s\", ENV{ID_PATH}==\"%s\", " \
-"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\", "
+"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\""
#define UDEV_RULE_FORMAT_NOTYPE \
-"ACTION==\"add\", SUBSYSTEM=\"block\", " \
+"ACTION==\"add\", SUBSYSTEM==\"block\", " \
"ENV{ID_PATH}==\"%s\", " \
-"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\", "
+"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\""
/* Write rule in the rule file. Use format from UDEV_RULE_FORMAT */
int write_rule(struct rule *rule, int fd, int force_part)
[at] [at] -807,9 +807,9 [at] [at] int write_rule(struct rule *rule, int fd, int force_part)
if (force_part)
typ = type_part;
if (typ)
- snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT, typ, pth);
+ snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT "\n", typ, pth);
else
- snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT_NOTYPE, pth);
+ snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT_NOTYPE "\n", pth);
return write(fd, line, strlen(line)) == (int)strlen(line);
}
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] fix: generated udev rules does not work due toincorrect line format
On Mon, 7 Mar 2011 09:56:48 +0000 "Hawrylewicz Czarnowski, Przemyslaw"
<przemyslaw.hawrylewicz.czarnowski [at] intel.com> wrote:
> Problem consists of missing =sign in comparison with SUBSYSTEM and
> missing new line character at the end of line. As a result incremental
> for hot-plugs of bare disks does not work.
>
> Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski [at] intel.com>
> ---
> policy.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/policy.c b/policy.c
> index afb640f..2a9fe5c 100644
> --- a/policy.c
> +++ b/policy.c
> [at] [at] -786,14 +786,14 [at] [at] char *find_rule(struct rule *rule, char *rule_type)
> }
>
> #define UDEV_RULE_FORMAT \
> -"ACTION==\"add\", SUBSYSTEM=\"block\", " \
> +"ACTION==\"add\", SUBSYSTEM==\"block\", " \
> "ENV{DEVTYPE}==\"%s\", ENV{ID_PATH}==\"%s\", " \
> -"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\", "
> +"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\""
>
> #define UDEV_RULE_FORMAT_NOTYPE \
> -"ACTION==\"add\", SUBSYSTEM=\"block\", " \
> +"ACTION==\"add\", SUBSYSTEM==\"block\", " \
> "ENV{ID_PATH}==\"%s\", " \
> -"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\", "
> +"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\""
>
> /* Write rule in the rule file. Use format from UDEV_RULE_FORMAT */
> int write_rule(struct rule *rule, int fd, int force_part)
> [at] [at] -807,9 +807,9 [at] [at] int write_rule(struct rule *rule, int fd, int force_part)
> if (force_part)
> typ = type_part;
> if (typ)
> - snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT, typ, pth);
> + snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT "\n", typ, pth);
> else
> - snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT_NOTYPE, pth);
> + snprintf(line, sizeof(line) - 1, UDEV_RULE_FORMAT_NOTYPE "\n", pth);
> return write(fd, line, strlen(line)) == (int)strlen(line);
> }
>
Applied (with a couple of minor changes), thanks.
NeilBrown
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html